###Education###



conf=.95
title="Education and Protest"
xlabel="Protest Topic"
ylabel="Change in Probability of Protest"
factor_labels=c("Reform","Military Rule")


# Get coefficients of variables
beta_1 =  .1461183  
beta_3 =  -.6433814  

# Create list of moderator values at which marginal effect is evaluated
x_2 <- c(0,1)

# Compute marginal effects
delta_1 = beta_1 + beta_3*x_2

# Compute variances
var_1 =     .02916538   + (x_2^2)*  .09509323   + 2*x_2*  -.03138586

# Standard errors
se_1 = se_1 = sqrt(var_1)

# Upper and lower confidence bounds
z_score = qnorm(1 - ((1 - conf)/2))
upper_bound = delta_1 + z_score*se_1
lower_bound = delta_1 - z_score*se_1

# Determine the bounds of the graphing area
max_y = max(upper_bound)
min_y = min(lower_bound)

# Initialize plotting window
plot(x=c(), y=c(), ylim=c(min_y, max_y), xlim=c(-.5, 1.5), xlab=xlabel, ylab=ylabel, main=title, xaxt="n")

# Plot points of estimated effects
points(x=x_2, y=delta_1, pch=16)

# Plot lines of confidence intervals
lines(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), lty=1)
points(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), pch=c(25,24), bg="black")
lines(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), lty=1)
points(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), pch=c(25,24), bg="black")

# Label the axis
axis(side=1, at=c(0,1), labels=factor_labels)

# Add a dashed horizontal line for zero
abline(h=0, lty=3)



conf=.95
title="Underemployment and Protest"
xlabel="Protest Topic"
ylabel="Change in Probability of Protest"
factor_labels=c("Reform","Military Rule")


# Get coefficients of variables
beta_1 =   -.6707264  
beta_3 =   1.770347 

# Create list of moderator values at which marginal effect is evaluated
x_2 <- c(0,1)

# Compute marginal effects
delta_1 = beta_1 + beta_3*x_2

# Compute variances
var_1 =     .14937745  + (x_2^2)* .34589422  + 2*x_2*  -.14153003 

# Standard errors
se_1 = se_1 = sqrt(var_1)

# Upper and lower confidence bounds
z_score = qnorm(1 - ((1 - conf)/2))
upper_bound = delta_1 + z_score*se_1
lower_bound = delta_1 - z_score*se_1

# Determine the bounds of the graphing area
max_y = max(upper_bound)
min_y = min(lower_bound)

# Initialize plotting window
plot(x=c(), y=c(), ylim=c(min_y, max_y), xlim=c(-.5, 1.5), xlab=xlabel, ylab=ylabel, main=title, xaxt="n")

# Plot points of estimated effects
points(x=x_2, y=delta_1, pch=16)

# Plot lines of confidence intervals
lines(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), lty=1)
points(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), pch=c(25,24), bg="black")
lines(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), lty=1)
points(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), pch=c(25,24), bg="black")

# Label the axis
axis(side=1, at=c(0,1), labels=factor_labels)

# Add a dashed horizontal line for zero
abline(h=0, lty=3)


conf=.95
title="Rural Location and Protest"
xlabel="Protest Topic"
ylabel="Change in Probability of Protest"
factor_labels=c("Reform","Military Rule")


# Get coefficients of variables
beta_1 =    .756319 
beta_3 =    -1.136763   

# Create list of moderator values at which marginal effect is evaluated
x_2 <- c(0,1)

# Compute marginal effects
delta_1 = beta_1 + beta_3*x_2

# Compute variances
var_1 =      .08998405   + (x_2^2)* .21887739 + 2*x_2*  -.09243936  

# Standard errors
se_1 = se_1 = sqrt(var_1)

# Upper and lower confidence bounds
z_score = qnorm(1 - ((1 - conf)/2))
upper_bound = delta_1 + z_score*se_1
lower_bound = delta_1 - z_score*se_1

# Determine the bounds of the graphing area
max_y = max(upper_bound)
min_y = min(lower_bound)

# Initialize plotting window
plot(x=c(), y=c(), ylim=c(min_y, max_y), xlim=c(-.5, 1.5), xlab=xlabel, ylab=ylabel, main=title, xaxt="n")

# Plot points of estimated effects
points(x=x_2, y=delta_1, pch=16)

# Plot lines of confidence intervals
lines(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), lty=1)
points(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), pch=c(25,24), bg="black")
lines(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), lty=1)
points(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), pch=c(25,24), bg="black")

# Label the axis
axis(side=1, at=c(0,1), labels=factor_labels)

# Add a dashed horizontal line for zero
abline(h=0, lty=3)


conf=.95
title="Support for Gender-Mixed Education and Protest"
xlabel="Protest Topic"
ylabel="Change in Probability of Protest"
factor_labels=c("Reform","Military Rule")


# Get coefficients of variables
beta_1 =    -.0530603    
beta_3 =  .4614068   

# Create list of moderator values at which marginal effect is evaluated
x_2 <- c(0,1)

# Compute marginal effects
delta_1 = beta_1 + beta_3*x_2

# Compute variances
var_1 =      .0167257      + (x_2^2)* .05195006   + 2*x_2*  -.0145217      

# Standard errors
se_1 = se_1 = sqrt(var_1)

# Upper and lower confidence bounds
z_score = qnorm(1 - ((1 - conf)/2))
upper_bound = delta_1 + z_score*se_1
lower_bound = delta_1 - z_score*se_1

# Determine the bounds of the graphing area
max_y = max(upper_bound)
min_y = min(lower_bound)

# Initialize plotting window
plot(x=c(), y=c(), ylim=c(min_y, max_y), xlim=c(-.5, 1.5), xlab=xlabel, ylab=ylabel, main=title, xaxt="n")

# Plot points of estimated effects
points(x=x_2, y=delta_1, pch=16)

# Plot lines of confidence intervals
lines(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), lty=1)
points(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), pch=c(25,24), bg="black")
lines(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), lty=1)
points(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), pch=c(25,24), bg="black")

# Label the axis
axis(side=1, at=c(0,1), labels=factor_labels)

# Add a dashed horizontal line for zero
abline(h=0, lty=3)



conf=.95
title="Party Support and Protest"
xlabel="Protest Topic"
ylabel="Change in Probability of Protest"
factor_labels=c("Reform","Military Rule")


# Get coefficients of variables
beta_1 =   .6548065    
beta_3 =   -1.301007   

# Create list of moderator values at which marginal effect is evaluated
x_2 <- c(0,1)

# Compute marginal effects
delta_1 = beta_1 + beta_3*x_2

# Compute variances
var_1 =     .09782269       + (x_2^2)*  .27669795   + 2*x_2*  -.1018895     

# Standard errors
se_1 = se_1 = sqrt(var_1)

# Upper and lower confidence bounds
z_score = qnorm(1 - ((1 - conf)/2))
upper_bound = delta_1 + z_score*se_1
lower_bound = delta_1 - z_score*se_1

# Determine the bounds of the graphing area
max_y = max(upper_bound)
min_y = min(lower_bound)

# Initialize plotting window
plot(x=c(), y=c(), ylim=c(min_y, max_y), xlim=c(-.5, 1.5), xlab=xlabel, ylab=ylabel, main=title, xaxt="n")

# Plot points of estimated effects
points(x=x_2, y=delta_1, pch=16)

# Plot lines of confidence intervals
lines(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), lty=1)
points(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), pch=c(25,24), bg="black")
lines(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), lty=1)
points(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), pch=c(25,24), bg="black")

# Label the axis
axis(side=1, at=c(0,1), labels=factor_labels)

# Add a dashed horizontal line for zero
abline(h=0, lty=3)


conf=.95
title="Central-East Region and Protest"
xlabel="Protest Topic"
ylabel="Change in Probability of Protest"
factor_labels=c("Reform","Military Rule")


# Get coefficients of variables
beta_1 =  -.6253318    
beta_3 =   1.737754    

# Create list of moderator values at which marginal effect is evaluated
x_2 <- c(0,1)

# Compute marginal effects
delta_1 = beta_1 + beta_3*x_2

# Compute variances
var_1 =     .14298761       + (x_2^2)*  .38785513    + 2*x_2* -.1683246     

# Standard errors
se_1 = se_1 = sqrt(var_1)

# Upper and lower confidence bounds
z_score = qnorm(1 - ((1 - conf)/2))
upper_bound = delta_1 + z_score*se_1
lower_bound = delta_1 - z_score*se_1

# Determine the bounds of the graphing area
max_y = max(upper_bound)
min_y = min(lower_bound)

# Initialize plotting window
plot(x=c(), y=c(), ylim=c(min_y, max_y), xlim=c(-.5, 1.5), xlab=xlabel, ylab=ylabel, main=title, xaxt="n")

# Plot points of estimated effects
points(x=x_2, y=delta_1, pch=16)

# Plot lines of confidence intervals
lines(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), lty=1)
points(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), pch=c(25,24), bg="black")
lines(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), lty=1)
points(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), pch=c(25,24), bg="black")

# Label the axis
axis(side=1, at=c(0,1), labels=factor_labels)

# Add a dashed horizontal line for zero
abline(h=0, lty=3)


###APPENDIX: Hizb-ut-Tahrir###



conf=.95
title="Support for Trade with EU and Coup Protest"
xlabel="Endorsement Prime"
ylabel="Change in Probability of Coup Protest Participation"
factor_labels=c("Some Politicians","Hizb-ut-Tahrir")


# Get coefficients of variables
beta_1 =  .5010356 
beta_3 =   -.8579722  

# Create list of moderator values at which marginal effect is evaluated
x_2 <- c(0,1)

# Compute marginal effects
delta_1 = beta_1 + beta_3*x_2

# Compute variances
var_1 =    .05433308   + (x_2^2)*  .10236569  + 2*x_2*  -.06282771 

# Standard errors
se_1 = se_1 = sqrt(var_1)

# Upper and lower confidence bounds
z_score = qnorm(1 - ((1 - conf)/2))
upper_bound = delta_1 + z_score*se_1
lower_bound = delta_1 - z_score*se_1

# Determine the bounds of the graphing area
max_y = max(upper_bound)
min_y = min(lower_bound)

# Initialize plotting window
plot(x=c(), y=c(), ylim=c(min_y, max_y), xlim=c(-.5, 1.5), xlab=xlabel, ylab=ylabel, main=title, xaxt="n")

# Plot points of estimated effects
points(x=x_2, y=delta_1, pch=16)

# Plot lines of confidence intervals
lines(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), lty=1)
points(x=c(x_2[1], x_2[1]), y=c(upper_bound[1], lower_bound[1]), pch=c(25,24), bg="black")
lines(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), lty=1)
points(x=c(x_2[2], x_2[2]), y=c(upper_bound[2], lower_bound[2]), pch=c(25,24), bg="black")

# Label the axis
axis(side=1, at=c(0,1), labels=factor_labels)

# Add a dashed horizontal line for zero
abline(h=0, lty=3)

